package com.erlang.spring.controller;

import com.erlang.spring.pojo.Account;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author ZGQ
 */
public class ClientController {

  @Autowired
  private Account account;
  /**
   * ApplicationContext:spring-IOC容器
   * ClassPathXmlApplicationContext：容器实现类，加载配置文件
   * applicationContext.getBean：获得容器中的bean对象
   */
  @Test
  public void saveAccount() {

    /**
     * Spring-IOC容器：ApplicationContext
     * 构建方式：通过ClassPathXmlApplicationContext加载配置文件
     * 使用bean:getBean
     */
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("bean.xml");
    Account account = (Account)applicationContext.getBean("account");
    System.out.println("account = " + account);
  }

}
